﻿
using HDSmartCommunity.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HDSmartCommunity.DAL
{
    public class FloorInfoDAL
    {
        public List<FloorInfo> GetAllFloor()
        {
            string strSql = "SELECT * FROM floor";

            CommFN<FloorInfo> fn = new CommFN<FloorInfo>();
            return fn.GetDataList(strSql);
        }

        public FloorInfo GetFloorByID(int fid)
        {
            string strSql = "SELECT * FROM floor where id=" + fid;

            CommFN<FloorInfo> fn = new CommFN<FloorInfo>();
            return fn.GetData(strSql);
        }

        public bool UpdateFloorInfoByID(FloorInfo info)
        {
            string strSql = string.Format("UPDATE floor SET physicsfloor={0},displayfloor='{1}',actualfloor={2} WHERE ID={3}", info.physicsfloor, info.displayfloor, info.actualfloor, info.ID);

            CommFN<FloorInfo> fn = new CommFN<FloorInfo>();
            return fn.ExecFN(strSql);
        }

        public bool InsertFloorInfo(FloorInfo info)
        {
            string strSql = string.Format("INSERT INTO floor(physicsfloor,displayfloor,actualfloor)VALUES({0},'{1}',{2})", info.physicsfloor, info.displayfloor, info.actualfloor);

            CommFN<FloorInfo> fn = new CommFN<FloorInfo>();
            return fn.ExecFN(strSql);
        }

        public bool DeleteFloorInfo(string ids)
        {
            string strSql = string.Format("DELETE FROM floor WHERE id in({0})", ids);

            CommFN<FloorInfo> fn = new CommFN<FloorInfo>();
            return fn.ExecFN(strSql);
        }
    }
}
